package org.sundatagroup.aurora.show.entity.status;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

/**
 * <p>向前台发送的展示的状态信息封装类, 就绪、准备
 * </p>
 * 
 * @author lui
 * @date 2018-04-20
 * @since 0.1.1
 */
public class ReadyStatus implements IStatusEntity {
	private String sid;
	private int pid;
	
	public ReadyStatus() {}
	
	ReadyStatus(JsonObject jo) {
		sid = jo.get("sid").getAsString();
		
		JsonElement je = jo.get("pid");
		if (je != null) {
			pid = je.getAsInt();
		}
	}

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public int getPid() {
		return pid;
	}

	public void setPid(int pid) {
		this.pid = pid;
	}

	public final DisplayStatus getStatus() {
        return DisplayStatus.READY;
    }
    
    @Override
    public JsonObject toJson() {
        JsonObject jo = new JsonObject();
        jo.addProperty("status", "ready");
        jo.addProperty("sid", sid);
        jo.addProperty("pid", pid);
        return jo;
    }
	
	@Override
	public String toString() {
		return "ReadyStatus " + toJson().toString();
	}
}
